package com.lizi.core.java.util.concurrent;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public class ThreadPoolExecutorExtend {

	private static final AtomicInteger count = new AtomicInteger();
	
	public static void main(String[] args) {
		ExecutorService pool1 = Executors.newSingleThreadExecutor();
		ExecutorService pool2 = Executors.newFixedThreadPool(20);
		ExecutorService pool3 = Executors.newCachedThreadPool();
		
		for (int i = 0; i < 1000; i++) {
			Thread thread = new Thread(new Runnable() {
				
				
				public void run() {
					int c = count.getAndIncrement();
					System.out.println(c + " : " + Thread.currentThread().getName());
				}
			});
			
			pool2.execute(thread);
		}
	}
}
